<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('角色分配用户')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="role-form">
                <input  type="hidden" name="id" id="id" th:value="${id}">
                <div class="select-list">
                    <ul>

                        <li>
                            园所名称：<input type="text" name="areaName"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

<!--        <div class="btn-group-sm" id="toolbar" role="group">-->
<!--            <a class="btn btn-success" onclick="addStaff()">-->
<!--                <i class="fa fa-plus"></i> 添加-->
<!--            </a>-->
<!--        </div>-->

        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var prefix = ctx + "sso/staff/";
    $(function () {
        var options = {
            url: prefix+"/staffIdByAreaList",
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    title: '园所ID'
                },
                {
                    field: 'areaName',
                    title: '园所名称'
                },
                {
                    field: 'adminStaffName',
                    title: '主管理员'
                },
                {
                    field: 'groupName',
                    title: '上级机构'
                },
                {
                    field: 'mobile',
                    title: '联系方式'
                },
                {
                    field: 'area',
                    title: '地域'
                },
                {
                    field: 'addr',
                    title: '详细地址'
                },
                {
                    field: 'space',
                    title: '面积'
                },
                {
                    field: 'academicCount',
                    title: '学位数'
                },
                {
                    field: 'classCount',
                    title: '班级数'
                },
                {
                    field: 'teacherCount',
                    title: '老师数'
                },
                {
                    field: 'areaId',
                    title: '默认园区',
                    formatter: function (value, row, index) {
                        if (row.areaId == row.id) {
                            return '<span class="label label-danger">是</span> ';
                        } else {
                            return '-';
                        }
                    }
                },
                {
                    field: 'remark',
                    title: '备注'
                }

                ,
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="setDefault(\'' + row.id + '\')"><i class="fa fa-edit"></i>设为默认</a> ');
                        return actions.join('');
                    }
                }
                ]
        };
        $.table.init(options);
    });

    /* 修改 */
    function setDefault(areaId) {
        var id= $("#id").val();
        $.modal.confirm("确认要将此角色设为默认吗？", function() {
            $.operate.post( "/sso/staff/edit", { "id": id,"areaId":areaId});
        })
    }
</script>
</body>
</html>